<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
	@IMPORT url("css/core.css");
</style>
<style type="text/css">

</style>
<script type="text/javascript" src="js/jquery-1.11.0.js"></script>
<script type="text/javascript">

	//用户名称是否可用
	var nameEnable = false;
	
	function regist(){
	 	var passwd = $("#passwd").val();
		var repasswd = $("#repasswd").val();
		if(passwd.length != 0 && passwd==repasswd && nameEnable){
			return true;
		}
		return false;
	}
	
	function checkUserName(input){
		var val = $(input).val();
		if(val.length != 0){
			$.post("checkuname.do",{name:val},function(data){
				if(data == 1){
					nameEnable = false;
					$("#check_user_sp").html("<font style=\"color: red;\">用户名已经被注册</font>");
				}else{
					$("#check_user_sp").html("<font style=\"color: green;\">ok!</font>");
					nameEnable = true;
				}
			});
		}
	}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>
</head>
<body>
	
	<form method="post" action="RegistServlet.do" onsubmit="return regist()">
		<%
			//request.getParameter("type").equals("-1");
			if("-1".equals(request.getParameter("type"))){
		%>
		 	<font style="color: red;">注册失败!</font>
		 <%		
			}
		 %>
		<br>
		<label>用户名:</label>
		<input onblur="checkUserName(this)"name="uname" type="text"><span id="check_user_sp"></span>
		<br>
		<label>密码:</label>
		<input id="passwd" name="passwd" type="password"><br>
		<label>确认密码:</label>
		<input id="repasswd"  name="repasswd" type="password"><br>
		<input style="margin-left: 170px" type="submit" value="注册">
	</form>
</body>
</html>